package com.sy.jtamqconsumer.listener;

import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sy.jtamqconsumer.dao.TestS1Reposity;
import com.sy.jtamqconsumer.pojo.TestS1;

/**
 * 
 * @author Administrator
 *
 */
@Service
@RocketMQMessageListener(topic = "test",consumerGroup = "test-group")
public class ConsumerListener implements RocketMQListener<TestS1> {
	private Logger logger = LoggerFactory.getLogger(ConsumerListener.class);
	@Autowired
  	private TestS1Reposity testS1Reposity;


	@Override
	public void onMessage(TestS1 s1) {
		logger.info("接收消息内容为: {}",s1);
		testS1Reposity.save(s1);
		logger.info("分布式事务保存成功");
	}
}
